package com.hc.model.code04.test6;

import java.util.ArrayList;
import java.util.List;

/**
 * @version v1.0
 * @ClassName: SubscriptionSubject
 * @Description: 具体的主题对象
 * @Author: HC
 */
public class SubscriptionSubject implements Subject {

    private List<Observer> weiXinObserverList = new ArrayList<>();

    @Override
    public void attach(Observer observer) {
        weiXinObserverList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        weiXinObserverList.remove(observer);
    }

    @Override
    public void notify(String message) {
        for (Observer observer : weiXinObserverList) {
            observer.update(message);
        }
    }
}
